package de.piratech.dasding.data.database.couch.adapters;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonDeserialize;

import de.piratech.dasding.data.Action;
import de.piratech.dasding.data.ActionCategory;
import de.piratech.dasding.data.Location;
import de.piratech.dasding.data.database.couch.DataType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class ActionAdapter extends Action {

	String rev;
	private DataType dataType;

	public ActionAdapter() {
		setCategory(getCategory());
		setContact(getContact());
		setDataType(getDataType());
		setDescription(getDescription());
		setFinalWorks(getFinalWorks());
		setFurtherInformation(getFurtherInformation());
		setId(getId());
		setLocation(getLocation());
		setName(getName());
		setParticipants(getParticipants());
		setResponsible(getResponsible());
		setStatus(getStatus());
		setTime(getTime());
	}

	public ActionAdapter(Action action) {
		setCategory(action.getCategory());
		setContact(action.getContact());
		setDescription(action.getDescription());
		setFinalWorks(action.getFinalWorks());
		setFurtherInformation(action.getFurtherInformation());
		setId(action.getId());
		setLocation(action.getLocation());
		setName(action.getName());
		setParticipants(action.getParticipants());
		setResponsible(action.getResponsible());
		setStatus(action.getStatus());
		setTime(action.getTime());
	}

	@JsonProperty("_id")
	public String getId() {
		return super.getId();
	}

	@JsonProperty("_rev")
	public String getRevision() {
		return this.rev;
	}

	public void setRevision(String rev) {
		this.rev = rev;
	}

	public DataType getDataType() {
		return this.dataType;
	}

	public void setDataType(DataType type) {
		this.dataType = type;
	}

	@Override
	@JsonDeserialize(as = LocationAdapter.class)
	public Location getLocation() {
		return super.getLocation();
	}

	@Override
	@JsonDeserialize(as = ActionCategoryAdapter.class)
	public ActionCategory getCategory() {
		return super.getCategory();
	}

	@Override
	@JsonIgnore
	public boolean isValid() {
		return super.isValid();
	}
}
